//
//  AISettingSwitchCell.m
//  Mia
//
//  Created by Vill on 2024/1/12.
//

#import "AISettingSwitchCell.h"

@implementation AISettingSwitchCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *ID = @"AISettingSwitchCell";
    AISettingSwitchCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
       cell = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
    }
    return cell;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [self.contentView addSubview:self.witch];
    self.witch.switchBlock = ^(BOOL isOn) {
        if (isOn){
            NSLog(@"打开了");
        }else{
            NSLog(@"关闭了");
        }
    };
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (ZYSwitch *)witch{
    if(!_witch){
        _witch = [[ZYSwitch alloc] initWithFrame:CGRectMake(KScreenWidth - PTW(70), PTW(21.5), PTW(50), PTW(25))];
        _witch.shapeType = ZYSwitchShapeTypeOval;
        _witch.onTintColor = [UIColor colorHex:@"#9387FF" alpha:1];
        _witch.tintColor = [UIColor colorHex:@"#FFFFFF" alpha:0.2];
        _witch.thumbTintColor = UIColor.whiteColor;
        _witch.on = true;
    }
    return _witch;
}


@end
